home *** CD-ROM | disk | FTP | other *** search
- Path: ix.netcom.com!netnews
- From: jdmorris@ix.netcom.com (Jason D. Morris)
- Newsgroups: comp.lang.c++
- Subject: Re: Why does this work?
- Date: Sat, 30 Mar 1996 03:32:43 GMT
- Organization: Netcom
- Message-ID: <315caa28.2883596@nntp.ix.netcom.com>
- References: <DoxvnA.L0C@mail.auburn.edu> <4jejr9$7a8@atlas.tncnet.com>
- NNTP-Posting-Host: pon-mi2-25.ix.netcom.com
- X-NETCOM-Date: Fri Mar 29 7:31:51 PM PST 1996
- X-Newsreader: Forte Agent .99d/32.182
-
- >>#include <iostream.h>
- >>#include <ctype.h>
- >>
- >>void main(void)
- >> {
- >> char letter;
- >>
- >> while (! cin.eof())
- >> {
- >> letter = cin.get();
- >> letter = toupper(letter);
- >> cout << letter;
- >> }
- >> }
- >>
- >>Why does this work!?!? It seems to reserve storage for only one
- >>character in letter, but outputs a whole line at a time. Feel free to
- >>flame my stupidity, but please satisfy my curiosity (I'm really not this
- >>clueless, I promise!!)
-
- Remember that i/o using cin/cout, and iostreams in general, is
- buffered. Therefore, what you type in at the console is held in a
- buffer until you press the enter key. At that point, the loop starts
- doing its work, reading input from the buffer and checking for EOF.
-
- Jason
-
-